﻿using System;
using System.Collections.Generic;
using Dsl.Ped.Common;
using Dsl.Ped.Common.Commands;
using Dsl.Ped.Framework.Common;

namespace Dsl.Ped.AddIn.Java.Projections.ClassTextProjection
{
    /// <summary>
    /// View model of <see cref="ClassTextProjection"/>
    /// </summary>
    public class ClassTextProjectionViewModel : ViewModelBase
    {
        #region Fields

        /// <summary>
        /// Inner projective object
        /// </summary>
        private IProjective projectiveObject;

        #endregion

        #region Members

        /// <summary>
        /// Action which is executed when the Back key is pressed
        /// </summary>
        public Action BackKeyAction { get; set; }

        /// <summary>
        /// Options and their command which reacts to the Enter key
        /// </summary>
        public List<IMenuCommand> EnterKeyOptions { get; set; }

        public IProjective ProjectiveContent
        {
            get
            {
                return projectiveObject;
            }
            set
            {
                projectiveObject = value;
                RaisePropertyChanged(() => ProjectiveContent);
            }
        }

        /// <summary>
        /// Options to be selected
        /// </summary>
        public List<IMenuCommand> Options
        {
            get
            {
                return EnterKeyOptions;
            }
        }

        #endregion 

        #region Constructors

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="projectiveContent">Inner projective object</param>
        /// <param name="enterKeyOptions">Options and their command to be displayed when the Enter button is pressed</param>
        /// <param name="backKeyAction">Action to be executed when the Back button is pressed</param>
        public ClassTextProjectionViewModel(
            IProjective projectiveContent,
            List<IMenuCommand> enterKeyOptions,
            Action backKeyAction)
        {
            ProjectiveContent = projectiveContent;
            EnterKeyOptions = enterKeyOptions;
            BackKeyAction = backKeyAction;
        }

        #endregion

        #region Methods

        public void Update()
        {
            var tempProjectiveObject = ProjectiveContent;
            ProjectiveContent = null;
            ProjectiveContent = tempProjectiveObject;
        }

        #endregion
    }
}
